class Render {
  constructor(layoutTree, context) {
    this.ctx = context
    this.traverse(layoutTree)
  }

  traverse(layoutTree) {
    for (let index = 0; index < layoutTree.length; index++) {
      const item = layoutTree[index]
      new {
        div: DivElement,
        img: ImageElement,
        text: TextElement,
        video: VideoElement,
        tree: TreeElement,
        star: StarElement
        // button: ButtonElement
      }[item.type](item, this.ctx).draw()
    }

    // if (!layoutTree || !layoutTree.children) return
    // for (let node of layoutTree.children) {
    //   this.traverse(node)
    // }
  }
}
